/*
 * Sender.cpp
 *
 *  Created on: Oct 2, 2012
 *      Author: Administrator
 */

#include "Sender.h"
#include "Util.h"

using namespace Osp::Base;
using namespace Osp::Base::Collection;
using namespace Osp::Base::Runtime;
using namespace Osp::Io;

Sender::Sender() {
	shotSender = Util::GetShotSender();
	shotStore = Util::GetShotStore();
	Construct();
	Start();
}

Sender::~Sender() {
	AppLog("Deleting Sender");
}

bool
Sender::OnStart(void) {
	AppLog("Sender starting");
	Test();
	return true;
}

void
Sender::OnStop(void) {
	AppLog("Sender stopping");
}

result
Sender::Construct(void)
{
   return Thread::Construct(THREAD_TYPE_EVENT_DRIVEN);
}

void
Sender::OnUserEventReceivedN(RequestId requestId, Osp::Base::Collection::IList *pArgs) {
	AppLog("OnUserEventReceivedN");
}

//Osp::Base::Object *
//Thread::Run(void) {
//	AppLog("Sender running");
//////	int counter = 1;
////	Shot* shot = shotStore->GetLastShot();
////	shotSender -> SendShot(shot);
////	while(true) {
////		Thread::GetCurrentThread()->Sleep(10000);
//////		AppLog("Try %d", counter++);
//////		AppLog(">>>");
////
//////		AppLog("<<<");
////	}
////	return null;
//}

void
Sender::Test(void) {
	Shot* shot = shotStore->GetLastShot();
	shotSender -> SendShot(shot);
}
